home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
m2
/
cat3src
/
cat
/
editutil.i
< prev
next >
Wrap
Text File
|
1997-10-26
|
47KB
|
1,473 lines
IMPLEMENTATION MODULE EditUtil;
FROM SYSTEM IMPORT ADDRESS, ADR, TSIZE, CADR, LOC, LONGWORD, WORD, ASSEMBLER, CAST, CALLSYS, BYTE;
(* Megamax-Lib *)
FROM Storage IMPORT ALLOCATE, DEALLOCATE, Inconsistent;
FROM GrafBase IMPORT LongRect, Rectangle, Point;
IMPORT Storage, Strings, BinOps, StrConv, Block,
MOSGlobals, Keyboard, Directory, Paths, ShellMsg;
FROM Keyboard IMPORT SpecialCode;
(* MagicLib *)
IMPORT MagicAES, MagicVDI, MagicDOS, mtAlerts, mtDir;
(* CAT Module *)
IMPORT CatFiles, MTE, CatGlobal;
FROM Void IMPORT v;
(* Editor *)
FROM EditTypes IMPORT EDITPTR, EDITOR, aLinePtr, aLineDesc, aLine, textPtr, bigTextPtr,
aMark, userProcType, userGetRectProc, drawUserProc, userCloseProc,
deskSize, pixOff, undoType, SuchFlags, SuchModus, searchDir,
searchPos, searchCount, CAT, CharSet, TrennSet, UmbruchSet,
userKeyProc, userTopProc, userUntopProc, userPrePrintProc,
userListProc, theDrawLine, aBufferPtr, aBuffer, LFIRST, LNEXT,
cursorHandle, maxBlocks;
IMPORT EditTypes;
FROM EditGlobals IMPORT ClipWork, GetTextWidth, AllocNew, GetQuote,
MouseArrow, MouseBusy, MouseHand,
HideMouse, ShowMouse, HideCursor,
SaveMouse, RestoreMouse,
ShowCursor, ForceCursor, drawCursor, RowToIndex,
SetDocument, CursorIsOn;
FROM EditTools IMPORT SetInfoLine, SetEditTitle, ShowFileChanged,
SetCurrLine, SetStartLine, getCharPos,
SaveLine, SaveOp, DeleteLine,
Undo, NewBlockToUndoBuffer,
SetBlockstart, SetBlockend,
GetClickLineAndRow, TestBlockMarksAndSwap, ToWordEnd,
ToWordStart, ToLineStart, ToLineEnd, MarkLine, MarkBlock,
ToBlockmark, SearchWord, ReplaceWord, FreeUndoBuffer;
FROM EditDraw IMPORT drawLine, redrawLine,
redrawLines, redrawWdw,
redrawLineArea, scrollRegion, CenterCurrline,
GetBlockRects, MarkArea;
IMPORT EditBase, EditFuncs, EditTools;
IMPORT WdwManager;
IMPORT ConfVars;
IMPORT Varnames;
IMPORT RectFuncs;
IMPORT QuickSort;
IMPORT CatEdit; (* zirkulrer Import in IMPLEMENTATION *)
(*$? CAT:
IMPORT Protokoll;
CONST progName = 'CAT:';
*)
(*$? NOT CAT:
IMPORT FredProtokoll;
CONST progName = 'Fred:';
*)
CONST
CR = 15C;
LF = 12C;
TAB = 11C;
emptyFile ='[2]['+progName+'|Die Datei ist leer!|Soll ein neuer Text|angelegt werden?][[Ja|:[Abbruch]';
newFile = '[2]['+progName+'|Die Datei existiert nicht!|Soll ein neuer Text|angelegt werden?][[Ja|:[Abbruch]';
noBackup = '[3]['+progName+'|Backup konnte nicht|angelegt werden!][:[Abbruch]';
onlyMonoFont = '[3]['+progName+'|Block einrcken geht nur|mit unproportionalen|Zeichenstzen!][[Ok]';
saveAsTitle = 'Sichern als...'+0C;
txtExt = '*.*';
cNoname = 'namenlos.txt';
PROCEDURE EditSaveWdwPos (wdw : INTEGER);
(* Sichert die Position des Editors in den
* Configvariablen
*)
VAR varName : ARRAY [0..255] OF CHAR;
full : Rectangle;
ed : EDITPTR;
BEGIN
ed := EditFuncs.FindEditor (wdw);
IF ed # NIL
THEN
WITH ed^ DO
Strings.Concat (cEditWindow, StrConv.IntToStr (number, 0), varName, v.bool);
WdwManager.GetWdwSize (wdw, full); (* Gre des Fensters abfragen *)
v.bool := ConfVars.SetConfigRect (varName, full);
Strings.Concat (cEditFont, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigInt (varName, font);
Strings.Concat (cEditSize, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigInt (varName, fontSize);
Strings.Concat (cEditTabs, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigBool (varName, realTabs);
Strings.Concat (cEditTabSize, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigInt (varName, tabSize);;
Strings.Concat (cEditWrap, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigBool (varName, umbruch);
Strings.Concat (cEditMargin, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigInt (varName, rightMargin);
Strings.Concat (cEditInfo, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigBool (varName, showInfo);
Strings.Concat (cEditZeile, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigLongInt (varName, ed^.currLineNr);
Strings.Concat (cEditRow, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigInt (varName, currRow);
Strings.Concat (cEditShowCr, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigBool (varName, showCR);
END;
END;
END EditSaveWdwPos;
PROCEDURE EditSavePos();
(* Sichert die Position und den Inhalt aller offenen Editorfenster
* (nicht ReadOnly-Fenster)
*)
VAR ed : EDITPTR;
varName : ARRAY [0..255] OF CHAR;
BEGIN
ed := EditFuncs.editList;
WHILE ed # NIL DO
WITH ed^ DO
IF fileName.length > 0
THEN
Strings.Concat (cEditFile, StrConv.IntToStr (number, 0), varName, v.bool);
v.bool := ConfVars.SetConfigString (varName, fileName.text^);
EditSaveWdwPos (wdw);
END;
END;
ed := ed^.nextEdit;
END;
END EditSavePos;
(* Einfge- und Lschoperationen *)
PROCEDURE IndentBlock (wdw : INTEGER);
VAR index, i, t: INTEGER;
Doit, Schirm: BOOLEAN;
blank: ARRAY [0..80] OF CHAR;
ed: EDITPTR;
Max: INTEGER; (* Maximale Zeilenlnge fr Einrcken! *)
PROCEDURE Ruecke (links: BOOLEAN);
VAR l: INTEGER;
BEGIN
WITH ed^ DO
ShowFileChanged(ed); (* Anzeigen, da Text gendert *)
IF index >= Max THEN RETURN END;
SetCurrLine (ed, blocks[0].blockStart.line);
REPEAT
(* YYYY Hier noch Anpassung auf CR/LF am Zeilenende einbauen! *)
l := editLen;
WHILE (l > 0) & ((editLine.text^[l-1] = CR) OR (editLine.text^[l-1] = LF)) DO DEC (l) END;
editChanged := TRUE;
IF (index > l) & ~links THEN
AllocNew (editLine, index+4);
Strings.Insert (Strings.Space (index-l), l, editLine.text^, v.bool);
l := index;
END (* IF index *);
IF (l >= index) THEN
IF links THEN
Strings.Delete (editLine.text^, index, 1, v.bool);
ELSE
AllocNew (editLine, index+INTEGER((*SYSTEM.*)LENGTH (blank))+2);
Strings.Insert (blank, index, editLine.text^, v.bool);
END (* IF links oder rechts ruecken *);
l := (*SYSTEM.*)LENGTH (editLine.text^);
editLen := l;
v.bool := EditBase.PutLine (ed, currLineNr, editLine.text^, l);
END (* IF Laenge *);
IF currLineNr # blocks[0].blockEnd.line THEN
SetCurrLine (ed, currLineNr+1);
END (* IF *);
UNTIL (currLineNr = blocks[0].blockEnd.line);
SetCurrLine (ed, blocks[0].blockStart.line);
currRow := index;
END (* WITH ed *);
END Ruecke;
VAR adr : RECORD a,b : ADDRESS; END;
taste, scan: INTEGER;
ch: CHAR;
key: MOSGlobals.Key;
frame: Rectangle;
BEGIN (* IndentBlock *)
ed := EditFuncs.FindEditor (wdw);
IF ed = NIL THEN RETURN END;
WITH ed^ DO
IF ~block THEN RETURN END;
IF ~monoSpaced THEN MTE.info (onlyMonoFont); RETURN END;
(* Block sichern fr Undo *)
SaveOp (ed, blockPaste, FALSE);
IF showInfo
THEN
(* Infozeile setzen *)
Strings.Assign (' Block einrcken (bei Cursor <-, ->), BS, Zeichen, RETURN fr Ende', WindowInfo, v.bool);
WdwManager.SetWdwInfoline (wdw, WindowInfo);
END;
(* Currline auf Blockanfang setzen *)
SetCurrLine (ed, blocks[0].blockStart.line);
currRow := blocks[0].blockStart.row;
CenterCurrline (ed);
(* Variablen initialisieren *)
blank [0] := ' '; blank [1] := 0C;
index := currRow;
Max := 512;
(* Menuzeile sperren und Window-Events verhindern *)
MagicAES.WindUpdate (MagicAES.BEGUPDATE);
MagicAES.WindUpdate (MagicAES.BEGMCTRL);
HideMouse();
(* Cursor zeigen *)
HideCursor (ed);
blockIndent := TRUE;
ShowCursor (ed);
REPEAT
Doit := FALSE;
Schirm := FALSE;
MagicAES.EvntKeybd (taste, scan, ch);
Keyboard.GemCharToKey (taste, 0, key);
IF Keyboard.IsSpecial (key)
THEN
CASE Keyboard.SpecialKey (key) OF
tab: t := tabSize * ((index DIV tabSize) + 1) - 1;
FOR i := index TO t DO
blank [i - index] := ' ';
END;
blank [t - index + 1] := 0C;
IF realTabs THEN
blank[0] := TAB;
blank[1] := 0C;
END;
Ruecke (FALSE);
HideCursor (ed);
IF realTabs
THEN
INC (currRow);
ELSE
INC (currRow, t -index + 1);
END;
ShowCursor (ed);
Doit := TRUE; Schirm := TRUE;
index := currRow; |
left,
wdLeft,
soln: IF currRow > 0 THEN
HideCursor (ed);
DEC (currRow);
ShowCursor (ed);
Doit := TRUE;
index := currRow;
END (* IF *); |
backspace: IF currRow > 0 THEN
HideCursor (ed); DEC (currRow); ShowCursor (ed);
Doit := TRUE; Schirm := TRUE;
index := currRow;
Ruecke (TRUE);
END (* IF *); |
right,
wdRight,
eoln: IF currRow < Max THEN
HideCursor (ed);
INC (currRow);
ShowCursor (ed);
Doit := TRUE;
index := currRow;
END (* IF *); |
delete: Ruecke (TRUE); Doit := TRUE; Schirm := TRUE;|
ELSE
END; (* CASE *)
ELSIF Keyboard.IsASCII (key)
THEN
blank [0] := ch; blank [1] := 0C;
Ruecke (FALSE);
Doit := TRUE; Schirm := TRUE;
IF currRow < Max THEN
HideCursor (ed);
INC (currRow);
ShowCursor (ed);
index := currRow;
END (* IF *);
END (* IF *);
IF Doit THEN
CenterCurrline (ed);
ShowFileChanged(ed); (* Anzeigen, da Text gendert *)
IF Schirm THEN
(* Hier noch richtigen Redrawaufruf hinsetzen *)
redrawLineArea (ed, blocks[0].blockStart.line, blocks[0].blockEnd.line);
END (* IF Schirm *);
END (* IF Doit *);
UNTIL (Keyboard.IsSpecial (key) & (Keyboard.SpecialKey (key) = return));
(* Noch Blockstart fr Undobuffer merken *)
NewBlockToUndoBuffer (ed);
(* Cursor zeigen *)
HideCursor (ed);
blockIndent := FALSE;
(* Blockmarken noch lschen *)
EditTools.ClearBlock (ed);
MagicAES.WindUpdate (MagicAES.ENDMCTRL);
MagicAES.WindUpdate (MagicAES.ENDUPDATE);
ShowCursor (ed);
ShowMouse(FALSE);
IF showInfo THEN SetInfoLine (ed); END;
END (* WITH ed^ *)
END IndentBlock;
(* Hilfsfunktionen fr OpenEditor und EditMerge *)
PROCEDURE getFileParms (REF path, FileName : ARRAY OF CHAR;
new : BOOLEAN; alerts : BOOLEAN;
VAR fn : aLineDesc; VAR flen : LONGCARD;
VAR fHdl : INTEGER) : BOOLEAN;
VAR newName : ARRAY [0..139] OF CHAR;
newPath : ARRAY [0..139] OF CHAR;
BEGIN
flen := 0;
fHdl := -1;
IF path[0] = 0C (* Pfad leer, aktuellen Pfad nehmen *)
THEN
(*$? NOT CAT:
Directory.GetDefaultPath (newPath);
*)
(*$? CAT:
mtDir.GetPath (newPath);
*)
ELSE
Strings.Assign (path, newPath, v.bool);
END;
(* Dateinamen zusammenbauen *)
IF FileName[0] # 0C THEN
fn.length := (*SYSTEM.*)LENGTH(newPath) + (*SYSTEM.*)LENGTH (FileName)+2;
ALLOCATE( fn.text, fn.length);
IF fn.text = NIL
THEN
(* not enough memory!! *)
EditFuncs.OutOfMem();
RETURN FALSE
END;
Strings.Concat (newPath, FileName, fn.text^, v.bool);
ELSE
fn.length := 0;
END;
(* File ffnen *)
fHdl := MagicDOS.Fopen (fn.text^, {});
(*$? NOT CAT:
(* Suchen im Pfad *)
IF fHdl < 0 THEN
(* file nicht geffnet *)
IF fHdl = MagicDOS.EFilNF
THEN
IF fn.length # 0
THEN
Paths.SearchFile (FileName, ShellMsg.SrcPaths, Paths.fromStart, v.bool, newName);
IF v.bool
THEN
DEALLOCATE (fn.text, 0);
ALLOCATE (fn.text, (*SYSTEM.*)LENGTH (newName)+2);
IF fn.text = NIL THEN HALT END;
Strings.Assign (newName, fn.text^, v.bool);
fHdl := MagicDOS.Fopen (fn.text^, {});
END;
END;
END;
END;
*)
IF fHdl < 0 THEN
IF fHdl = MagicDOS.EFilNF THEN
IF alerts & ~new THEN
v.int := mtAlerts.Alert (1,newFile);
IF v.int = 2
THEN
RETURN FALSE
ELSE
RETURN TRUE
END;
ELSE
RETURN TRUE;
END;
ELSE
fn.length := 0;
DEALLOCATE (fn.text, 0);
fn.text := NIL;
IF alerts THEN CatFiles.ErrorAlert (fHdl); END;
RETURN FALSE
END;
END;
(* Filegre feststellen *)
flen := MagicDOS.Fseek (0, fHdl, MagicDOS.SeekEnd);
v.lcard := MagicDOS.Fseek (0, fHdl, MagicDOS.SeekStart);
IF (flen = 0) & ~new
THEN
(* Lohnt sich nicht :-) *)
v.int := mtAlerts.Alert (1,emptyFile);
IF v.int = 2
THEN
(* Abbruch gewhlt *)
RETURN FALSE
END;
END;
RETURN TRUE;
END getFileParms;
PROCEDURE testMem (flen : LONGCARD; VAR memSize : LONGCARD;
VAR fastRead : BOOLEAN) : BOOLEAN;
BEGIN
(* freien Speicher feststellen, mindestens 30 kB frei! *)
memSize := flen;
memSize := Storage.MemAvail();
IF memSize < (2 * flen + ((flen DIV 100) * 115) + 4096L)
THEN
IF memSize < (flen DIV 100) * 115 + 4096L
THEN
(* not enough memory, just don't try any more *)
EditFuncs.OutOfMem();
RETURN FALSE
ELSE
(* knnte klappen, versuchen wir mal die langsame Methode! *)
fastRead := FALSE;
END;
ELSE
fastRead := TRUE;
END;
RETURN TRUE;
END testMem;
PROCEDURE getReadBuff (memSize, flen : LONGCARD; VAR readBuf : ADDRESS) : BOOLEAN;
VAR voidBuf : ADDRESS;
bufSize : LONGCARD;
BEGIN
(* 2 * Max(TextSize, 10 kB) allozieren *)
memSize := Storage.MemAvail();
IF memSize > 4 * flen
THEN
(* wir haben VIEL Speicher *)
IF memSize > flen + 32000
THEN
bufSize := BinOps.HigherLCard (memSize-flen-32000, 10*1024);
ELSE
bufSize := 10*1024
END;
ELSE
bufSize := BinOps.HigherLCard ( (flen DIV 100) * 115 + 8192L, 10*1024);
IF memSize > flen + 32000
THEN
bufSize := BinOps.LowerLCard (bufSize, memSize-flen-32000);
END;
END;
ALLOCATE (voidBuf, bufSize);
IF (voidBuf = NIL) THEN
(* Not enough memory *)
(* melden *)
EditFuncs.OutOfMem();
RETURN FALSE
END;
ALLOCATE (readBuf, flen+2);
IF readBuf = NIL THEN
(* Not enough memory *)
EditFuncs.OutOfMem();
DEALLOCATE (voidBuf, 0);
RETURN FALSE
END;
(* 1 Buffer wieder freigeben *)
DEALLOCATE (voidBuf, 0);
RETURN TRUE
END getReadBuff;
PROCEDURE EditPasteFile (wdw: INTEGER; isFilter: BOOLEAN; REF path, name: ARRAY OF CHAR);
(* Fgt einen Text mit Filename ein
*)
VAR flen : LONGCARD;
memSize : LONGCARD;
ed : EDITPTR;
readBuf : POINTER TO ARRAY [0L..$FFFFFFFF] OF CHAR;
bufSize : LONGCARD;
fastRead : BOOLEAN;
fn : aLineDesc;
fHdl : INTEGER;
scrLine : INTEGER;
wasBlock : BOOLEAN;
inLine : BOOLEAN;
PROCEDURE FreeStuff();
(* Dealloziert allozierte Pointer und gibt sonstiges Zeugs frei
*)
BEGIN
IF readBuf # NIL THEN DEALLOCATE (readBuf, 0) END;
IF fHdl > 0 THEN v.int := MagicDOS.Fclose (fHdl); CatFiles.ErrorAlert (v.int) END;
IF fn.text # NIL THEN DEALLOCATE (fn.text, 0) END;
END FreeStuff;
BEGIN
ed := EditFuncs.FindEditor (wdw);
IF ed # NIL
THEN
readBuf := NIL;
IF ed^.readOnly & ~isFilter THEN RETURN END;
IF getFileParms (path, name, TRUE, FALSE, fn, flen, fHdl) & (flen > 0)
THEN
(* HideMouse ();
HideCursor (ed); *)
WITH ed^ DO
scrLine := SHORT(ed^.currLineNr - ed^.StartLine);
DEALLOCATE (fn.text, 0);
v.int := MagicDOS.Fclose (fHdl);
IF flen > 0
THEN
wasBlock := ed^.block;
IF ed^.block THEN
SaveOp (ed, blockPaste, FALSE);
v.bool := EditFuncs.cutBlock (ed, FALSE, FALSE);
blocks[0].blockStart.line := currLineNr;
blocks[0].blockStart.row := currRow;
block := TRUE;
ELSE
SetBlockstart (ed);
SaveOp (ed, normalPaste, FALSE);
block := TRUE;
END;
inLine := currRow # 0;
IF NOT ( (* Dateinamen basteln, Datei ffnen und Lnge feststellen *)
getFileParms (path, name, FALSE, FALSE, fn, flen, fHdl) &
(* Speicher feststellen und auf flen testen *)
testMem(flen, memSize, fastRead) &
(* Lesebuffer allozieren *)
getReadBuff (memSize, flen, readBuf) &
(* Text einlesen und einfgen *)
EditFuncs.readText (ed, fastRead, flen, fHdl, ed^.rightMargin, readBuf, ~inLine, FALSE)
)
THEN
FreeStuff;
(*
ShowCursor (ed);
ShowMouse (FALSE);
*)
RETURN
END;
HideMouse ();
HideCursor (ed);
EditTools.UpdateCurrLine (ed, currLineNr);
ShowFileChanged (ed);
IF fn.text # NIL THEN DEALLOCATE (fn.text, 0) END;
NewBlockToUndoBuffer (ed);
(* Jetzt Cursorposition anpassen an Ende des gepasteten Stcks
*)
SetCurrLine (ed, blocks[0].blockEnd.line);
currRow := blocks[0].blockEnd.row;
SetDocument (ed);
IF ~wasBlock THEN
(* normal Paste *)
block := FALSE;
blocks[0].blockStart.line := -1;
blocks[0].blockEnd.line := -1;
END;
WdwManager.RedrawWdw (wdw, editWork);
CenterCurrline (ed);
IF showInfo THEN SetInfoLine (ed) END;
ShowCursor (ed);
ShowMouse (FALSE);
END;
END; (* WITH ed^ *)
END;
END;
END EditPasteFile;
PROCEDURE SaveText (VAR ed : EDITPTR; saveas : BOOLEAN; takeName: BOOLEAN; REF fpath, fname : ARRAY OF CHAR) : BOOLEAN;
VAR line : aLinePtr;
path : ARRAY [0..130] OF CHAR;
name : ARRAY [0..12] OF CHAR;
fullName : ARRAY [0..145] OF CHAR;
fHdl : INTEGER;
len : LONGCARD;
isOpen: BOOLEAN;
appended : BOOLEAN;
i : INTEGER;
BEGIN
isOpen := FALSE;
appended := FALSE;
WITH ed^ DO
IF editChanged THEN
v.bool := EditBase.PutCurrLine (ed);
END;
IF new & ~saveas
THEN
IF fileName.length = 0
THEN
(*$? NOT CAT:
Directory.GetDefaultPath (path);
*)
(*$? CAT:
mtDir.GetPath (path);
*)
Strings.Assign (cNoname,name, v.bool);
IF CatGlobal.FselGet (path, name, txtExt, saveAsTitle, FALSE)
THEN
Strings.Concat (path, name, fullName, v.bool);
fHdl := MagicDOS.Fopen (fullName, {MagicDOS.Write});
IF fHdl # MagicDOS.EFilNF
THEN
IF fHdl > MagicDOS.EOK
THEN
v.int := mtAlerts.Alert (2,MTE.Overwrite);
IF v.int = 2 THEN
len := MagicDOS.Fseek (0, fHdl, MagicDOS.SeekEnd);
appended := TRUE;
ELSIF v.int = 3 THEN
v.int := MagicDOS.Fclose (fHdl);
CatFiles.ErrorAlert (v.int);
RETURN FALSE
ELSE
(* Schlieen und Fcreate machen *)
v.int := MagicDOS.Fclose (fHdl);
fHdl := MagicDOS.Fcreate (fullName, {});
IF fHdl < MagicDOS.EOK
THEN
CatFiles.ErrorAlert (fHdl);
RETURN FALSE;
END;
END;
appended := v.int = 2;
ELSE
CatFiles.ErrorAlert (fHdl);
RETURN FALSE
END;
ELSE (* IF fHdl # EFilNF *)
(* File not found: Create *)
fHdl := MagicDOS.Fcreate (fullName, {});
IF fHdl < MagicDOS.EOK
THEN
CatFiles.ErrorAlert (fHdl);
RETURN FALSE
END;
END; (* IF fHdl # EFilNF *)
ELSE
RETURN FALSE
END; (* IF FselGet *)
isOpen := TRUE;
END (* IF fileName.length = 0 *);
END (* IF new *);
IF ~isOpen
THEN
IF (fname[0] # "")
THEN
Strings.Concat (fpath, fname, fullName, v.bool);
ELSE
Strings.Assign (fileName.text^, fullName, v.bool);
END;
fHdl := MagicDOS.Fopen (fullName, {MagicDOS.Write});
IF (fHdl < MagicDOS.EOK) THEN
IF (fHdl = MagicDOS.EFilNF) THEN
fHdl := MagicDOS.Fcreate (fullName, {});
IF fHdl < MagicDOS.EOK THEN
CatFiles.ErrorAlert (fHdl);
RETURN FALSE
END;
ELSE
CatFiles.ErrorAlert (fHdl);
RETURN FALSE
END;
ELSE
IF saveas
THEN
v.int := mtAlerts.Alert (2,MTE.Overwrite);
IF v.int = 2 THEN
(* Anhngen *)
len := MagicDOS.Fseek (0, fHdl, MagicDOS.SeekEnd);
appended := TRUE;
ELSIF v.int = 3 THEN
(* Abbruch *)
v.int := MagicDOS.Fclose (fHdl);
CatFiles.ErrorAlert (v.int);
RETURN FALSE
ELSE (* v.int = 1 *)
(* berschreiben *)
(* Schlieen und Fcreate machen *)
v.int := MagicDOS.Fclose (fHdl);
fHdl := MagicDOS.Fcreate (fullName, {});
IF fHdl < MagicDOS.EOK
THEN
CatFiles.ErrorAlert (fHdl);
RETURN FALSE;
END;
END;
ELSE
(* Direkt berschreiben *)
(* Schlieen und Fcreate machen *)
v.int := MagicDOS.Fclose (fHdl);
(*$? NOT CAT:
IF backup THEN
IF ~CatGlobal.CreateBackup (fullName)
THEN
v.int := mtAlerts.Alert (1,noBackup);
RETURN FALSE
END;
END;
*)
fHdl := MagicDOS.Fcreate (fullName, {});
IF fHdl < MagicDOS.EOK
THEN
CatFiles.ErrorAlert (fHdl);
RETURN FALSE;
END;
END;
END;
END (* IF ~isOpen *);
(* So, jetzt ist garantiert ein File offen, wir knnen endlich schreiben *)
IF block & saveas
THEN
FOR i := 0 TO maxBlocks - 1 DO
WITH blocks[i] DO
IF (blockStart.line >= 0) & (blockEnd.line >= 0)
THEN
v.bool := EditFuncs.outputText (ed, blockStart.line, blockStart.row,
blockEnd.line, blockEnd.row, fHdl, umbruch, FALSE);
END;
END;
END;
ELSE
v.bool := EditFuncs.outputText (ed, 0, 0, -1, -1, fHdl, umbruch, FALSE);
END;
v.int := MagicDOS.Fclose (fHdl);
CatFiles.ErrorAlert (v.int);
IF v.int # MagicDOS.EOK THEN RETURN FALSE
ELSE
IF (takeName & ((saveas & ~block & (fname[0] # "")) OR (new & ~block)) & ~appended & ~readOnly)
THEN
(* hier noch Assign auf Filename *)
fileName.length := (*SYSTEM.*)LENGTH(fullName) + 1;
IF fileName.text # NIL THEN DEALLOCATE (fileName.text, 0); END;
ALLOCATE (fileName.text, fileName.length);
IF fileName.text = NIL
THEN
(* not enough memory!! *)
EditFuncs.OutOfMem();
RETURN FALSE
END;
Strings.Assign (fullName, fileName.text^, v.bool);
END;
IF ~(block & saveas)
THEN
changed := FALSE;
END;
END;
SetEditTitle (ed);
(*$? CAT:
Protokoll.SendPathUpdate (fullName);
*)
(*$? NOT CAT:
FredProtokoll.SendPathUpdate (fullName);
*)
END (* WITH ed DO *);
RETURN TRUE;
END SaveText;
PROCEDURE PerformDragDrop (ed : EDITPTR; x, y: INTEGER; kstate, buts: BITSET);
VAR outline: ARRAY [0..maxBlocks - 1] OF ARRAY [0..20] OF Point;
outRects: ARRAY [0..maxBlocks - 1 ] OF ARRAY [0..3] OF Rectangle;
count : INTEGER;
pIdx : ARRAY [0..maxBlocks-1] OF INTEGER;
i : INTEGER;
deltaX,
deltaY,
oldX,
oldY : INTEGER;
style: CARDINAL;
bl : INTEGER;
BEGIN
WITH ed^ DO
(* get block rectangles *)
FOR bl := 0 TO maxBlocks - 1 DO
IF (blocks[bl].blockStart.line >= 0) & (blocks[bl].blockEnd.line >= 0)
THEN
GetBlockRects (ed, outRects[bl], count, blocks[bl].blockStart.line, blocks[bl].blockStart.row, blocks[bl].blockEnd.line, blocks[bl].blockEnd.row);
ELSE
count := 0
END;
(* now calculate outline points of rectangles *)
pIdx[bl] := 0;
IF count > 0
THEN
outline[bl][pIdx[bl]].x := outRects[bl][0].x;
outline[bl][pIdx[bl]].y := outRects[bl][0].y;
INC (pIdx[bl]);
outline[bl][pIdx[bl]].x := outRects[bl][0].w+1;
outline[bl][pIdx[bl]].y := outRects[bl][0].y;
INC (pIdx[bl]);
outline[bl][pIdx[bl]].x := outRects[bl][0].w+1;
outline[bl][pIdx[bl]].y := outRects[bl][0].h+1;
INC (pIdx[bl]);
(* walk down right edge *)
FOR i := 1 TO count - 1 DO
outline[bl][pIdx[bl]].x := outRects[bl][i].w+1;
outline[bl][pIdx[bl]].y := outRects[bl][i].y;
INC (pIdx[bl]);
outline[bl][pIdx[bl]].x := outRects[bl][i].w+1;
outline[bl][pIdx[bl]].y := outRects[bl][i].h+1;
INC (pIdx[bl]);
END;
(* Jetzt rckwrts die linke Kante hoch *)
FOR i := count - 1 TO 0 BY -1 DO
outline[bl][pIdx[bl]].x := outRects[bl][i].x;
outline[bl][pIdx[bl]].y := outRects[bl][i].h+1;
INC (pIdx[bl]);
outline[bl][pIdx[bl]].x := outRects[bl][i].x;
outline[bl][pIdx[bl]].y := outRects[bl][i].y;
INC (pIdx[bl]);
END;
END;
END;
(* Jetzt haben wir eine Outline, da sind zwar mglicherweise doppelte
* Punkte drin, aber das ist egal
*)
oldX := x;
oldY := y;
MagicAES.WindUpdate (MagicAES.BEGMCTRL);
ShowMouse(FALSE);
MouseHand();
(* Writemode auf XOR setzen *)
v.int := MagicVDI.SetWritemode (hdl, MagicVDI.XOR);
(* Linestyle etc. setzen *)
v.int := MagicVDI.SetLinetype (hdl, MagicVDI.User);
IF ODD (x)
THEN
style := $AAAA;
ELSE
style := $5555;
END;
MagicVDI.SetUserlinestyle (hdl, style);
v.int := MagicVDI.SetLinewidth (hdl, 1);
v.int := MagicVDI.SetLinecolor (hdl, 1);
(* Clipping setzen *)
WdwManager.SetClip (hdl, WdwManager.deskSize, TRUE);
(* Linie zeichnen *)
HideMouse();
FOR bl := 0 TO maxBlocks - 1 DO
IF pIdx[bl] > 0
THEN
MagicVDI.Polyline (hdl, pIdx[bl], outline[bl]);
END;
END;
ShowMouse(FALSE);
REPEAT
MagicAES.GrafMkstate (x, y, buts, kstate);
IF (x # oldX) OR (y # oldY)
THEN
HideMouse();
FOR bl := 0 TO maxBlocks - 1 DO
IF pIdx[bl] > 0
THEN
(* Linie wieder wegzeichnen an alten Koordinaten *)
MagicVDI.Polyline (hdl, pIdx[bl], outline[bl]);
(* Koordinaten anpassen *)
deltaX := x - oldX;
deltaY := y - oldY;
FOR i := 0 TO pIdx[bl] - 1 DO
INC (outline[bl][i].x, deltaX);
INC (outline[bl][i].y, deltaY);
END;
(* Neue Outline zeichnen *)
MagicVDI.Polyline (hdl, pIdx[bl], outline[bl]);
END;
END;
ShowMouse(FALSE);
oldX := x;
oldY := y;
END;
UNTIL ~(0 IN buts);
(* Outline wieder wegzeichnen *)
HideMouse();
FOR bl := 0 TO maxBlocks - 1 DO
IF pIdx[bl] > 0
THEN
MagicVDI.Polyline (hdl, pIdx[bl], outline[bl]);
END;
END;
ShowMouse(FALSE);
(* Writemode zurcksetzen *)
v.int := MagicVDI.SetWritemode (hdl, MagicVDI.REPLACE);
(* Clipping auf Workbereich setzen *)
ClipWork (ed);
MagicAES.WindUpdate (MagicAES.ENDMCTRL);
(* Drag und Drop ausfhren *)
MagicAES.WindUpdate (MagicAES.ENDUPDATE);
v.bool := WdwManager.WdwDDServe (wdw, x, y, kstate);
MagicAES.WindUpdate (MagicAES.BEGUPDATE);
(* Mauszeiger zurcksetzen *)
MouseArrow();
HideMouse();
END;
END PerformDragDrop;
PROCEDURE ClickIsInBlock (wdw : INTEGER; x, y: INTEGER) : BOOLEAN;
(* Gibt zurck, ob die Position x, y im Blockbereich liegt
*)
VAR ed : EDITPTR;
clLine : LONGINT;
clRow : INTEGER;
oLine : LONGINT;
oRow : INTEGER;
BEGIN
IF ~CatEdit.BlockIsMarked (wdw) THEN RETURN FALSE END;
ed := EditFuncs.FindEditor (wdw);
IF ed # NIL
THEN
WITH ed^ DO
oRow := currRow;
oLine := currLineNr;
IF RectFuncs.IsInRect (x, y, editWork)
THEN
GetClickLineAndRow (ed, x, y, clLine, clRow);
SetCurrLine (ed, oLine);
currRow := oRow;
WITH blocks[0] DO
IF ( (clLine > blockStart.line) OR
((clLine = blockStart.line) & (clRow >= blockStart.row)) ) &
( (clLine < blockEnd.line) OR
((clLine = blockEnd.line) & (clRow <= blockEnd.row)) )
THEN
RETURN TRUE
END;
END;
END;
END;
END;
RETURN FALSE;
END ClickIsInBlock;
PROCEDURE CheckWildAssign (VAR search, repl: ARRAY OF CHAR): BOOLEAN;
(* Prft die Konsistenz von Wildcards und ihren Gegenstcken im Such-
* und Ersetzstring
*)
VAR one, all : CHAR;
numC : CHAR;
i : INTEGER;
oneC,
allC : CARDINAL;
M : INTEGER;
BEGIN
one := EditTypes.wildOneChar;
all := EditTypes.wildAllChar;
M := (*SYSTEM.*)LENGTH (search); (* Anzahl der Zeichen im Suchstring *)
(* Jetzt erstmal alle Wildcardzeichen am Anfang und am Ende lschen,
* die sind berflssig
*)
WHILE ((search [0] = one)
OR (search [0] = all)) DO
Strings.Delete (search, 0, 1, v.bool);
END;
M := (*SYSTEM.*)LENGTH (search); (* Anzahl der Zeichen im Suchstring *)
WHILE (M > 1) & ((search[M-1] = all) OR (search[M-1] = one)) DO
search[M-1] := 0c; DEC (M);
END;
oneC := 0;
i := 0;
LOOP
i := Strings.Pos (one, search, i);
IF i >= 0 THEN INC (oneC); INC (i)
ELSE
EXIT
END;
END;
allC := 0;
i := 0;
LOOP
i := Strings.Pos (all, search, i);
IF i >= 0 THEN INC (allC); INC (i)
ELSE
EXIT
END;
END;
(* Jetzt haben wir die Anzahl der Wildcards im Suchstring *)
IF (oneC > 10) OR (allC > 10) THEN RETURN FALSE END;
(* Jetzt den Ersetzstring prfen *)
i := 0;
LOOP
i := Strings.Pos (one, repl, i);
IF i >= 0 THEN
(* Nchstes Zeichen testen, ob es eine Nummer ist *)
numC := repl[i+1];
IF (numC >= '0') & (numC <= '9')
THEN
IF (ORD (numC) - ORD ('0')) >= oneC
THEN
RETURN FALSE
END;
END;
INC (i);
ELSE
EXIT
END;
END;
i := 0;
LOOP
i := Strings.Pos (all, repl, i);
IF i >= 0 THEN
(* Nchstes Zeichen testen, ob es eine Nummer ist *)
numC := repl[i+1];
IF (numC >= '0') & (numC <= '9')
THEN
IF (ORD (numC) - ORD ('0')) >= allC
THEN
RETURN FALSE
END;
END;
INC (i);
ELSE
EXIT
END;
END;
RETURN TRUE;
END CheckWildAssign;
PROCEDURE MarkMultiple (ed: EDITPTR);
VAR index, i, t: INTEGER;
Doit, Schirm: BOOLEAN;
blank: ARRAY [0..80] OF CHAR;
Max: INTEGER; (* Maximale Zeilenlnge fr Einrcken! *)
PROCEDURE DoEvent (VAR scan, char: CHAR; VAR taste: INTEGER; VAR kstate: BITSET);
VAR mBuff: ARRAY [0..15] OF INTEGER;
dr : RECORD
CASE :BOOLEAN OF
TRUE : x,y,w,h : INTEGER|
FALSE: adr, dum: ADDRESS
END
END;
evnt : BITSET;
doExit : BOOLEAN;
moX, moY : INTEGER;
moButton : BITSET;
bReturn : INTEGER;
sc : INTEGER;
BEGIN
evnt := MagicAES.EvntMulti({MagicAES.MUKEYBD}, 0,{},{}, 0,dr, 0,
dr, mBuff, 0, 0, moX, moY, moButton, taste, kstate, sc, char, bReturn);
scan := CHAR(SHORT(sc));
END DoEvent;
CONST maxMarks = (maxBlocks - 1) * 2 - 1;
VAR adr : RECORD a,b : ADDRESS; END;
taste : INTEGER;
scan, ch : CHAR;
kstate : BITSET;
key : MOSGlobals.Key;
frame : Rectangle;
oldLine : LONGINT;
oldRow : INTEGER;
marked : BOOLEAN;
wasMarked : BOOLEAN;
ctrl : BOOLEAN;
lastMark : INTEGER;
highMark : INTEGER;
marks,
markSort : ARRAY [0..maxMarks] OF aMark;
PROCEDURE SortMark (a1, a2: ADDRESS): BOOLEAN;
VAR m1, m2: POINTER TO aMark;
BEGIN
m1 := a1;
m2 := a2;
IF m1^.line < 0
THEN
RETURN FALSE;
END;
RETURN (m1^.line < m2^.line) OR
((m1^.line = m2^.line) & (m1^.row < m2^.row));
END SortMark;
PROCEDURE RemoveTwoMarks(REF which: aMark);
VAR i, k : INTEGER;
rmvCount : INTEGER;
BEGIN
i := 0;
rmvCount := 0;
WHILE (i <= highMark) & (rmvCount < 2) DO
IF (which.line = marks[i].line)
& (which.row = marks[i].row)
THEN
IF i = lastMark
THEN
INC (i);
ELSE
(* marks[i] entfernen *)
FOR k := i TO highMark-1 DO
marks[k] := marks[k+1];
END;
DEC (highMark);
IF lastMark > i
THEN
DEC (lastMark);
END;
INC (rmvCount);
END;
ELSE
INC (i);
END;
END;
END RemoveTwoMarks;
PROCEDURE MarkToBlocks();
VAR i : INTEGER;
high : INTEGER;
BEGIN
IF ODD (highMark)
THEN
high := highMark
ELSE
high := highMark - 1
END;
markSort := marks;
v.bool := QuickSort.sortIt (0, high, markSort, SortMark, TSIZE (aMark), QuickSort.noBreak);
FOR i := 0 TO maxBlocks-1 DO
ed^.blocks[i].blockStart.line := -1;
ed^.blocks[i].blockEnd.line := -1;
END;
FOR i := 0 TO high BY 2 DO
IF (markSort[i].line # markSort[i+1].line)
OR (markSort[i].row # markSort[i+1].row)
THEN
ed^.blocks[i DIV 2].blockStart := markSort[i];
ed^.blocks[i DIV 2].blockEnd := markSort[i+1];
ed^.multiBlockIdx := i DIV 2;
ELSE
RemoveTwoMarks(markSort[i]);
END;
END;
END MarkToBlocks;
BEGIN (* MarkMultiple *)
IF ed = NIL THEN RETURN END;
WITH ed^ DO
(* vorhandene Blockmarkierung lschen *)
EditTools.ClearBlock (ed);
block := FALSE;
multiBlockIdx := 0;
lastMark := 0;
highMark := 0;
CenterCurrline (ed);
(* Variablen initialisieren *)
(* Menuzeile sperren und Window-Events verhindern *)
MagicAES.WindUpdate (MagicAES.BEGUPDATE);
MagicAES.WindUpdate (MagicAES.BEGMCTRL);
HideMouse();
(* Cursor zeigen *)
HideCursor (ed);
blockIndent := TRUE;
multiBlockMark := TRUE;
wasMarked := FALSE;
FOR i := 0 TO maxMarks DO
marks[i].line := -1;
marks[i].row := -1;
END;
marks[0].line := currLineNr;
marks[0].row := currRow;
ShowCursor (ed);
REPEAT
oldLine := currLineNr;
oldRow := currRow;
(* Event holen *)
DoEvent (scan, ch, taste, kstate);
Keyboard.GemCharToKey (taste, SHORT (INTEGER(kstate)), key);
marked := CatGlobal.WithShift (kstate);
IF marked # wasMarked
THEN
INC (lastMark);
IF (lastMark > maxMarks) OR (highMark > maxMarks)
THEN
DEC (lastMark);
(* Abbrechen, maximale Anzahl Marken erreicht *)
CatGlobal.Bing (1);
key.ch := 'Q';
key.ctrl := MOSGlobals.CtrlSet{};
key.scan := 0;
END;
highMark := BinOps.HigherInt (highMark, lastMark);
END;
ctrl := CatGlobal.WithCtrl (kstate);
IF ctrl
THEN
kstate := {MagicAES.KCTRL};
ELSE
kstate := {};
END;
IF Keyboard.IsSpecial (key)
THEN
CASE Keyboard.SpecialKey (key) OF
home: EditFuncs.Home (ed, FALSE); |
clr: marked := FALSE; (* Nicht markieren! *)
EditFuncs.Home (ed, TRUE); |
soln,
wdLeft,
left: EditFuncs.CursorLeft (ed, kstate); |
eoln,
wdRight,
right: EditFuncs.CursorRight (ed, kstate); |
pgUp,
up: EditFuncs.CursorUp (ed, ctrl); |
pgDown,
down: EditFuncs.CursorDown (ed, ctrl); |
ELSE
END; (* CASE *)
END (* IF *);
IF marked & ((oldLine # currLineNr) OR (oldRow # currRow))
THEN
MarkArea (ed, oldLine, oldRow, currLineNr, currRow, TRUE);
END;
marks[lastMark].line := currLineNr;
marks[lastMark].row := currRow;
wasMarked := marked;
IF marked & ((oldLine # currLineNr) OR (oldRow # currRow))
THEN
MarkToBlocks ();
END;
UNTIL (Keyboard.IsASCII (key) & (CAP(key.ch) = 'Q'));
(* Cursor zeigen *)
HideCursor (ed);
multiBlockMark := FALSE;
blockIndent := FALSE;
block := CatEdit.BlockIsMarked (ed^.wdw);
ShowCursor (ed);
ShowMouse(FALSE);
MagicAES.WindUpdate (MagicAES.ENDMCTRL);
MagicAES.WindUpdate (MagicAES.ENDUPDATE);
END (* WITH ed^ *)
END MarkMultiple;
PROCEDURE JoinLine (ed: EDITPTR);
VAR len : INTEGER;
newLen : INTEGER;
qLen : INTEGER;
quoteStr : ARRAY [0..127] OF CHAR;
newText : textPtr;
BEGIN
WITH ed^ DO
IF EditBase.GetLineLength (ed, currLineNr+1, len)
THEN
(* temporre Zeile allozieren *)
ALLOCATE (newText, len + 2);
IF newText = NIL THEN RETURN END;
(* Neue Lnge berechnen *)
newLen := len + editLen;
AllocNew (editLine, newLen+2);
(* nchste Zeile holen *)
v.bool := EditBase.GetLine (ed, currLineNr+1, newText^, len);
(* Quote holen *)
GetQuote (editLine.text^, quoteStr);
qLen := LENGTH (quoteStr);
editLine.text^[editLen-1] := '';
Strings.Delete (newText^, 0, qLen, v.bool);
Strings.Append (newText^, editLine.text^, v.bool);
editLen := LENGTH (editLine.text^);
editChanged := TRUE;
v.bool := EditBase.PutCurrLine (ed);
v.bool := EditBase.DeleteLine (ed, currLineNr+1);
IF currLineNr < StartLine
THEN
DEC (StartLine);
END;
DEALLOCATE (newText, 0);
END;
END;
END JoinLine;
PROCEDURE BuildOriginalText (ed: EDITPTR);
VAR cLine: LONGINT;
BEGIN
(* Jetzt die Zeilen durchgehen *)
WITH ed^ DO
cLine := 0;
SetCurrLine (ed, 1);
WHILE cLine < totalLineNr DO
SetCurrLine (ed, cLine);
IF editLine.text^[editLen-1] = CR
THEN
(* Hier haben wir umgebrochen *)
JoinLine (ed);
ELSE
INC (cLine);
END;
END;
END;
END BuildOriginalText;
VAR fastWrap: BOOLEAN;
PROCEDURE TextWidth (ed: EDITPTR; REF str: ARRAY OF CHAR; idx: INTEGER; VAR width: INTEGER);
VAR extend : ARRAY [0..3] OF Point;
BEGIN
IF fastWrap
THEN
IF idx < (32767 DIV ed^.charWidth)
THEN
width := idx * ed^.charWidth;
ELSE
width := 32767;
END;
ELSE
GetTextWidth (ed, str, idx, extend);
width := extend[1].x - extend[0].x;
END;
END TextWidth;
PROCEDURE WrapLine (ed: EDITPTR; maxWdwWidth: INTEGER);
VAR width: INTEGER;
lastIdx,
idx : INTEGER;
quoteStr : ARRAY [0..127] OF CHAR;
BEGIN
WITH ed^ DO
idx := LENGTH (editLine.text^);
REPEAT
TextWidth (ed, editLine.text^, idx, width);
IF (width > maxWdwWidth)
THEN
(* umbrechen *)
lastIdx := idx;
IF monoSpaced
THEN
idx := (maxWdwWidth DIV charWidth) - 1;
ELSE
IF width = 32767
THEN
idx := BinOps.LowerInt ((maxWdwWidth * 7 DIV 5) DIV charWidth, idx);
ELSE
(* Erstmal eine Annherung berechnen *)
DEC (idx, (width - maxWdwWidth) DIV charWidth);
END;
END;
idx := BinOps.LowerInt (idx, lastIdx);
DEC (idx);
WHILE (idx > 0) & (editLine.text^[idx] # ' ') DO
DEC (idx);
END;
IF idx = 0
THEN
(* Zwangsumbrechen im Wort *)
idx := BinOps.LowerInt (lastIdx, (maxWdwWidth * 7 DIV 5) DIV charWidth);
WHILE (width > maxWdwWidth) & (idx > 0) DO
DEC (idx);
TextWidth (ed, editLine.text^, idx, width);
END;
IF idx = 0
THEN
idx := lastIdx; (* kein Umbruch *)
width := maxWdwWidth;
END;
END;
END;
UNTIL width <= maxWdwWidth;
IF idx < INTEGER(LENGTH (editLine.text^))
THEN
(* umbrechen, Zeile bei idx trennen *)
INC (idx);
GetQuote (editLine.text^, quoteStr);
(* Wir basteln den Quote nur zusammen, wenn das *)
AllocNew (editLine, INTEGER(LENGTH (editLine.text^) + LENGTH (quoteStr) + 5));
Strings.Insert (CR, idx, editLine.text^, v.bool);
IF idx > INTEGER(LENGTH (quoteStr))
THEN
Strings.Insert (quoteStr, idx+1, editLine.text^, v.bool);
INC (editLen, LENGTH (quoteStr) + 1);
ELSE
INC (editLen, 1);
END;
(* Zeile in Buffer schreiben *)
editChanged := TRUE;
v.bool := EditBase.PutCurrLine (ed);
(* Zeile trennen *)
v.bool := EditBase.InsertCr (ed, currLineNr, idx+1);
IF currLineNr < StartLine
THEN
INC (StartLine);
END;
END;
END;
END WrapLine;
PROCEDURE WrapText (ed: EDITPTR; force: BOOLEAN): BOOLEAN;
VAR cLine : LONGINT;
saveLine : LONGINT;
mWidth : INTEGER;
wdwWidth : INTEGER;
work : Rectangle;
BEGIN
(* Umbruch berhaupt eingeschaltet *)
IF ~force
THEN
IF ed^.fileName.text # NIL
THEN
RETURN FALSE;
END;
ConfVars.GetConfDefBool (cViewWrap, v.bool, TRUE);
IF ~v.bool THEN RETURN FALSE END;
END;
ConfVars.GetConfDefBool (cViewFastWrap, fastWrap, FALSE);
(* Reservebreite holen *)
TextWidth (ed, " ", 2, mWidth);
(* Umbruchbreite berechnen *)
wdwWidth := ed^.editWork.w - pixOff - mWidth;
(* Keine nderung? Raus hier! *)
IF wdwWidth = ed^.lastWrapWidth THEN RETURN FALSE END;
MouseBusy();
IF ed^.block
THEN
EditTools.ClearBlock (ed);
END;
(* Text wieder in Originalform bringen *)
saveLine := ed^.currLineNr;
BuildOriginalText (ed);
(* Jetzt die Zeilen durchgehen *)
WITH ed^ DO
(* Umbruchbreite merken *)
lastWrapWidth := wdwWidth;
cLine := 0;
WHILE cLine < totalLineNr DO
SetCurrLine (ed, cLine);
WrapLine (ed, wdwWidth);
INC (cLine);
END;
maxWidth := 0;
SetCurrLine (ed, saveLine);
currLineNr := saveLine;
END;
MouseArrow();
RETURN TRUE;
END WrapText;
END EditUtil.